package com.base_java.common;


import com.google.common.collect.Sets;

import java.util.Set;

/**
 * @description:
 * @author: mingtai
 * @createDate: 0:58 2020/4/14
 * @version: 1.0
 */

/**
 * 常量类
 * 需要大写，符合规范
 * @author: mingtai
 */
public class Const {

    public static final String CURRENT_USER = "currentUser";

    public static final String EMAIL = "email";
    public static final String USERNAME = "username";

    public static final String DOMAIN = "http://app.base_javasmart.net:8090";
    public static final String ACTIVATION_PATH = "/base_java/user/activation.do?";
    public static final String START_EMAIL_HTML = "你好，这是一封注册激活邮件，请点击链接 <a href=";
    public static final String END_EMAIL_HTML = ">激活链接</a> 完成注册，" + "<br>注册完成才能进行接下来的操作";

    public static final String MACID = "macId";
    public static final String TASKNAME = "taskName";

    public interface ProductListOrderBy {
        Set<String> PRICE_ASC_DESC = Sets.newHashSet("price_desc", "price_asc");
    }

    public interface Cart {
        int CHECKED = 1;//购物车选中状态
        int UN_CHECKED = 0; //购物车未选中

        String LIMIT_NUM_FAIL = "LIMIT_NUM_FAIL";
        String LIMIT_NUM_SUCCESS = "LIMIT_NUM_SUCCESS";
    }

    public interface Role {
        int ROLE_CUSTOMER = 0;//普通用户
        int ROLE_ADMIN = 1; //管理员
    }

    public interface ActivationStatus {
        Integer NO_STATUS_ACTIVATION = 0;// 未激活状态
        Integer YES_STATUS_ACTIVATION = 1; //已激活
    }

    // 是否隐藏
    public interface DeleteStatus {
        // 隐藏
        Integer DELETE_STATUS_YES = 0;
        // 不隐藏
        Integer DELETE_STATUS_NO = 1;
    }

    // 审批状态
    public interface ApprovalStatus {
        // 未审批
        Integer APPROVAL_STATUS_NO = 0;
        // 审批通过
        Integer APPROVAL_STATUS_YES = 1;
        // 审批未通过
        Integer APPROVAL_STATUS_REJECT = 2;

    }


    public enum ProductStatusEnum {
        ON_SALE(1, "在线");
        //属性
        private String value;
        private int code;

        //再来一个构造器
        ProductStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }
    }

    public enum PaymentTypeEnum {
        ONLINE_PAY(1, "在线支付");

        PaymentTypeEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        private String value;
        private int code;

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static PaymentTypeEnum codeOf(int code) {
            for (PaymentTypeEnum paymentTypeEnum : values()) {
                if (paymentTypeEnum.getCode() == code) {
                    return paymentTypeEnum;
                }

            }
            throw new RuntimeException("没有对应的枚举类型");
        }
    }


    public enum OrderStatusEnum {
        CANCELED(0, "已取消"),
        NO_PAY(10, "未支付"),
        PAID(20, "已付款"),
        SHIPPED(40, "已发货"),
        ORDER_SUCCESS(50, "订单完成"),
        ORDER_CLOSE(60, "订单关闭");

        OrderStatusEnum(int code, String value) {
            this.code = code;
            this.value = value;
        }

        private int code;
        private String value;

        public int getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }

        public static OrderStatusEnum codeOf(int code) {
            for (OrderStatusEnum orderStatusEnum : values()) {
                if (orderStatusEnum.getCode() == code) {
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("没有对应的枚举类型");
        }


    }

}
